package edu.sctu.zhoudie.mouth201505.day20150517.TextTwo;

/**
 * Created by user08 on 2015/5/17.
 */
//创建另一个类老师所教学生Student，该类有学号，姓名，成绩，年龄，性别，住址。

public class TextMore {
    Teacher[] teachers = new Teacher[10];
    Student[] students = new Student[5];

    public void sotrNumber() {



        for (int a = 0; a < teachers.length; a++) {
            Teacher teacher = new Teacher();
            teacher.setNumber(10 - a);
            teacher.setName("zs" + a);
            teacher.setProfession("教授" + a);
            teacher.setSex("男" + a);
            for (int c = 0; c < students.length; c++) {
                Student student = new Student();
                student.setNumber(01 + c);
                student.setName("李四" + c);
                student.setGrade(63 - c);
                student.setAge(18 + c);
                student.setSex("nan" + c);
                student.setAddress("四川" + c);
                students[c] = student;
            }


            teacher.setStudent(students);
            teachers[a] = teacher;
        }
            Teacher b;
            for (int i = 0; i < teachers.length - 1; i++) {
                for (int j = 0; j < teachers.length - 1; j++) {


                if (teachers[i].getNumber() > teachers[i + 1].getNumber()) {

                    b = teachers[i];
                    teachers[i] = teachers[i + 1];
                    teachers[i + 1] = b;
                }
                }



           }
        for (int i = 0; i < teachers.length; i++) {


            System.out.println(teachers[i].getNumber() + teachers[i].getName());
        }

        }


    Student n ;
    public void sortStudent() {
        for (int m = 0; m < students.length - 1; m++) {
            if (students[m].getGrade() > students[m + 1].getGrade()) {
                n = students[m];
                students[m] = students[m+1];
                students[m+1] = n;

            }
            System.out.println(students[m].getGrade()+students[m].getName());
        }

    }

    public void pritCoded() {
        for (int i = 0; i < teachers.length - 1; i++) {

            if (teachers[i].getProfession().equals("教授") ) {
                System.out.println(teachers[i].getName()+teachers[i].getProfession());
            }
        }
    }
}


//创建一个类为TextOne,TextOne继承自TextMore，TextMore有三个方法，sotrNumber()一个是对老师学号
//        进行排序，sortStudent()一个是对老师所教学生成绩进行排序。pritCoded()一个是对老师职称为教授的进行返回